\fBGuard\fP provides a so called \fBtype secure cast\fP. It tests whether the object referred to by \fBobjectPointer\fP is kind of the class \fBclassName\fP (see \fImacro IsKindOf\fP). If that is the case it returns \fBobjectPointer\fP casted to \fBclassName *\fP. Otherwise it reports an error and returns \fBNULL\fP.
.br
Example:
.na
.nf
VObject *vop = new TextItem (/* ... */);
TextItem *ti;
if (ti = Guard(vop,TextItem)) // successful
ti-\>SetString("xxxxx");
EditTextItem *eti;
if (eti = Guard(vop,EditTextItem)) // returns NULL and reports an error
eti-\>SetSelection();
.ad b
.fi
macro \fBGuard\fP is sometimesused.
.SH ARGUMENTS
.TP
\fBObjPtr objectPointer
.br
refers to the object whose class is checked and it is then casted to \fBclassName *\fP
.TP
\fBname className
.br
the name of the class which the object in \fBobjectPointer\fP should be an instance of
.SH CATEGORIES
.na
metaclass
.ad b
.SH FILES
.PD 0
.TP 20
declaration:
\fBObject.h
.SH KNOWN PROBLEMS
\fBGuard\fP is sometimes called in ET++ without checking the return value (e.g. several methods of the \fIclass Menu\fP and the \fIclass Window\fP).
.br
.br
.B Notice:
.SH HISTORY
joe@csesbg.at Mon Jun 17 19:47 1991 reworked
.br
joe@csesbg.at Wed Jun 19 18:24 1991 added IsKindOf, Guard